import sqlite3

def saveDataToSqlite(data,sqlName):
	sql = sqlite3.connect('/Users/mac/Desktop/imagesDB.sqlite')
	curs = sql.cursor()
	sqlStr = 'create table if not exists ' + sqlName + '(id integer primary key autoincrement, url text not null, type text not null, size integer not null);'
	curs.execute(sqlStr)
	insert='insert into ' + sqlName + ' values(NULL,?,?,?)'
	curs.execute(insert, data)
	sql.commit()
	sql.close()

def queryData():
	sql = sqlite3.connect('/Users/mac/Desktop/gitlearn/data/database/link.db')
	curs = sql.cursor()
	curs.execute('select * from LINK')
	for row in curs.fetchall():
		uid = row[0]
		url = row[1]
		
		if uid <= 5000:

			saveDataToSqlite((url,'0',200),'imageOne')

		elif uid > 5000 and uid <= 10000:
		
			saveDataToSqlite((url,'0',200),'imageTwo')
		
		elif uid > 10000 and uid <= 15000:
			
			saveDataToSqlite((url,'0',200),'imageThr')

		elif uid > 15000:

			saveDataToSqlite((url,'0',200),'imageFor')

queryData()		













